css: Add _gtk_css_matcher_matches_any()
authorAlexander Larsson <alexl@redhat.com>
Wed, 28 Nov 2012 10:07:52 +0000 (11:07 +0100)
committerAlexander Larsson <alexl@redhat.com>
Fri, 30 Nov 2012 13:53:29 +0000 (14:53 +0100)
This returns true if the matcher matches *anything*. We need
to check this later, because such matchers are dangerous in loops
that iterate over all parents/siblings since such loops would not
terminate.

gtk/gtkcssmatcher.c
gtk/gtkcssmatcherprivate.h

index c656ef48e7e2b60e15eaea45f643d511f45c77b9..68207387fef8f729726b16707001c8f854e4a989 100644 (file)
@@ -185,6 +185,7 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_WIDGET_PATH = {
   gtk_css_matcher_widget_path_has_regions,
   gtk_css_matcher_widget_path_has_region,
   gtk_css_matcher_widget_path_has_position,
+  FALSE
 };
 
 gboolean
@@ -288,6 +289,7 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_ANY = {
   gtk_css_matcher_any_has_regions,
   gtk_css_matcher_any_has_region,
   gtk_css_matcher_any_has_position,
+  TRUE
 };
 
 void
@@ -406,6 +408,7 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_SUPERSET = {
   gtk_css_matcher_superset_has_regions,
   gtk_css_matcher_superset_has_region,
   gtk_css_matcher_superset_has_position,
+  FALSE
 };
 
 void
index 1b4c632ff9aac9171cafe925532602a8a8716b1d..28810b2ca304fe4a4a9dc924a780055543f309e7 100644 (file)
@@ -50,6 +50,7 @@ struct _GtkCssMatcherClass {
                                                    gboolean               forward,
                                                    int                    a,
                                                    int                    b);
+  gboolean is_any;
 };
 
 struct _GtkCssMatcherWidgetPath {
@@ -146,6 +147,12 @@ _gtk_css_matcher_has_position (const GtkCssMatcher *matcher,
   return matcher->klass->has_position (matcher, forward, a, b);
 }
 
+static inline gboolean
+_gtk_css_matcher_matches_any (const GtkCssMatcher *matcher)
+{
+  return matcher->klass->is_any;
+}
+
 
 G_END_DECLS